<template>
  <div class="coupons" :style="{ '--btn_color': btn_color }">
    <div class="title">
      <span></span>
      <div>我的优惠券</div>
      <span></span>
      <div class="triangle_left_border"></div>
      <div class="triangle_right_border"></div>
    </div>

    <div class="gift_pop">
      <vm-scrollbar tag="div" :wrapStyle="{ height: height + 'px' }">
        <div v-show="prizeLists.length">
          <div class="the_price">
            <div class="container">
              <div class="stamp stamp01">
                <div class="leftBox">
                  <div>{{ val.desc }}</div>
                  <div class="price" v-if="val.resource == 1">
                    {{ val.preferential_amount }}元
                  </div>
                  <div class="price" v-else>
                    {{ val.discount }}<span>折</span>
                  </div>
                  <div v-show="val.price != 0">订单满{{ val.price }}元可用</div>
                  <div v-show="val.price == 0">无门槛使用</div>
                </div>
                <div class="rightBox">
                  {{ val.resource == 1 ? "优惠" : "折扣" }}券
                </div>
                <i></i>
              </div>
            </div>
          </div>

          <div
            class="panle_data"
            v-for="(item, i) in prizeLists"
            :key="i"
            v-if="prizeLists"
          >
            <div class="panle_time">
              <span>优惠券总数</span>
              <span>{{ item.receive_num || 0 }}</span>
            </div>
            <div class="panle_time">
              <span>未使用次数</span>
              <span>{{ item.unuse_num || 0 }}</span>
            </div>
            <div class="panle_time" style="border-right: 0">
              <span>使用次数</span>
              <span>{{ item.user_num || 0 }}</span>
            </div>
          </div>

          <div class="prize_type">
            <van-button
              :style="{ backgroundColor: bnt_color }"
              class="button"
              size="mini"
              @click="verificationClick(prizeLists[0])"
              >核销</van-button
            >
          </div>
        </div>

        <!-- <div
          class="conter"
          v-for="(item, i) in prizeLists"
          :key="item.order_id"
          v-if="prizeLists"
        >
          <div class="text3">
            <div class="avatarandname">
              <div class="content_left">
                <span>{{item.title}}</span>
                <span class="name">券数量{{ item.createtime }}</span>
              </div>
              
            </div>


            
          </div>
        </div> -->
        <nodata-piz v-show="!prizeLists.length"></nodata-piz>
      </vm-scrollbar>
    </div>
  </div>
</template>

<script>
import { Icon, Image as VanImage, Button, Toast } from "vant";
import NodataPiz from "./NodataPiz.vue";
export default {
  components: {
    [Icon.name]: Icon,
    [VanImage.name]: VanImage,
    [Button.name]: Button,
    [Toast.name]: Toast,
    NodataPiz,
  },
  props: {
    activityItem: {
      type: Object,
      required: true,
    },
    openid: {
      type: String,
      required: true,
    },
    prizeLists: {
      type: Array,
      required: true,
    },
  },
  data() {
    return {
      btn_color: "",
      introduce: [],
      activity_id: null,
      height: null,
      val: {},
      isShowp: true,
    };
  },
  created() {
    this.btn_color = this.activityItem.btn_color;
    this.introduce = this.activityItem.introduce;
    this.activity_id = this.activityItem.id;
    this.val = this.activityItem.coupon;
    // this.getPrizeList();
    console.log(this.activityItem, "activityItem");
  },
  mounted() {
    console.log("132456", this.prizeLists);
    this.height = document.documentElement.clientHeight * 0.37;
    // console.log(this.activityItem, 'activityItem');
  },
  methods: {
    // getPrizeList() {
    //   let params = { activity_id: this.activity_id, openid: this.openid };
    //   this.$request.prizeList(params).then((res) => {
    //     this.prizeLists = res.data.data;
    //     // console.log(this.prizeLists, "this.prizeLists");
    //   });
    // },
    // 奖品核销
    verificationClick(item) {
      console.log(item);
      if (item.receive_num == item.user_num)
        return this.$toast("没有多余优惠券,无法核销");
      this.$store.commit("setOrderItem", item);
      this.$router.push("/caseShow/lottoActivity/ApplyPZS");
    },
  },
};
</script>

<style lang="scss" scoped>
.coupons {
  margin: 3.5rem 0 1rem 0;
  width: 90%;
  background-color: #fff;
  border-radius: 8px;
  padding: 1.5rem 1rem 1rem;
  box-sizing: border-box;
  position: relative;
  .title {
    width: 12rem;
    height: 3rem;
    background: var(--btn_color);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    line-height: 3rem;
    text-align: center;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
    letter-spacing: 0.3rem;
    font-size: 1.4rem;
    span {
      display: inline-block;
      width: 1rem;
      height: 1rem;
      border-radius: 1rem;
      background-color: #ffdb89;
    }
    span:nth-child(1) {
      margin-right: 0.5rem;
    }
    span:nth-child(2) {
      margin-left: 0.2rem;
    }
    .triangle_left_border {
      width: 0;
      height: 0;
      border-bottom: 1.5rem solid var(--btn_color);
      border-left: 1.5rem solid transparent;
      position: absolute;
      left: 0%;
      top: 0%;
      margin-left: -1.5rem;
    }
    .triangle_right_border {
      width: 0;
      height: 0;
      border-bottom: 1.5rem solid var(--btn_color);
      border-right: 1.5rem solid transparent;
      position: absolute;
      left: 100%;
      top: 0%;
    }
  }

  .gift_pop {
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    // align-items: center;
    height: auto;
    background-color: white;
    position: relative;
    padding: 1rem 0;
    // overflow-y: scroll;
    .the_price {
      .stamp {
            width: 100%;
            /* height: 140px; */
            padding: 13px 15px;
            position: relative;
            overflow: hidden;
            color: white;
            display: flex;
            align-items: center;
            background-color: var(--theme_color);
            // background-image: radial-gradient(rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 5px,var(--theme_color) 5px);
            // background-size: 15px 15px;
            // background-position: 9px 3px;
            
            i {
              position: absolute;
              left: 20%;
              top: 45px;
              height: 190px;
              width: 390px;
              background-color: rgba(255, 255, 255, 0.15);
              transform: rotate(-30deg);
            }
            .leftBox {
              flex: 7;
              border-right: 2px dashed rgba(255, 255, 255, 0.3);
              text-align: left;
              
              .price {
                padding-top: 10px;
                padding-bottom: 10px;
                font-size: 24px;
                span {
                  font-size: 16px;
                  margin-left: 5px;
                }
              }
              div {
              }
            }
            .rightBox {
              margin-left: 10px;
              text-align: center;
              flex: 3;
            }
          }
          .stamp::after {
              content: '';
              position: absolute;
              height: 100%;
              width:5px;
              top: 0px;
              left: 0px;
              background-image: linear-gradient(to bottom, #ffffff 5px, transparent 5px, transparent),
              radial-gradient(5px circle at 5px 10px, transparent 5px, #ffffff 5px);
              background-size: 4px 15px;
            }
          .stamp::before {
              content: '';
              position: absolute;
              height: 100%;
              width:5px;
              top: 0px;
              right: 0px;
              background-image: linear-gradient(to bottom, #ffffff 5px, transparent 5px, transparent),
              radial-gradient(5px circle at 5px 10px, transparent 5px, #ffffff 5px);
              background-size: 4px 15px;
            }
      // .container {
        
      //   .price {
      //     position: absolute;
      //     top: 50%;
      //     left: 8%;
      //     font-size: 2rem;
      //     margin-top: -1rem;
      //     color: red;
      //     font-weight: bold;
      //   }
      //   .mask {
      //     position: absolute;
      //     width: 10rem;
      //     height: 10rem;
      //     top: 2rem;
      //     right: 0;
      //     // background-color:red;
      //   }
      //   .prices {
      //     position: absolute;
      //     top: 50%;
      //     left: 13%;
      //     font-size: 2rem;
      //     margin-top: -1rem;
      //     color: red;
      //     font-weight: bold;
      //   }
      //   .line {
      //     position: absolute;
      //     z-index: 999;
      //     margin-left: 2rem;
      //     top: 4rem;
      //     left: 10rem;
      //     width: 2px;
      //     height: 6.5rem;
      //     background: #af5d00;
      //   }
      //   .font {
      //     position: absolute;
      //     z-index: 999;
      //     left: 13rem;
      //     top: 50%;
      //     margin-top: -1.5rem;
      //     font-size: 16px;
      //   }
      // }
    }

    .panle_data {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      border-top: 1px solid #fafafa;
      padding-bottom: 10px;
      padding-top: 12px;
      .panle_time {
        width: 33%;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 8px 0;
        border-right: 1px solid #fafafa;
        border-bottom: 1px solid #fafafa;
        span {
          // margin: 8px 0;
        }
        :nth-child(1) {
          color: #a3a3a3;
        }
        :nth-child(2) {
          margin: 12px 0 0;
          color: #333333;
          font-weight: 600;
        }
      }
    }
    .prize_type {
      text-align: right;
      margin-right: 12px;
      .button {
        margin-left: 10px;
        background-color: var(--btn_color);
        border: 0;
        color: #fff;
      }
    }
  }
}
</style>